﻿
<input class="layui-input" type="text" name="StartDate" id="StartDate" />
<input class="layui-input" type="text" name="EndDate" id="EndDate" />
<script>
    $(document).ready(function() {

        layui.use(function() {

            var laydate = layui.laydate;


            //执行一个laydate实例
            var tbNewStartDate = laydate.render({
                elem: "#StartDate",
                done: function(value, date) {
                    tbNewFinishDate.config.min = {
                        year: date.year,
                        month: date.month - 1,
                        date: date.date,
                        hours: 0,
                        minutes: 0,
                        seconds: 0
                    };
                    if ($.trim(value) == "") {
                        tbNewFinishDate.config.min = tbNewStartDate.config.min;
                        tbNewStartDate.config.max = tbNewFinishDate.config.max;
                    }
                }
            });
            var tbNewFinishDate = laydate.render({
                elem: "#EndDate",
                done: function(value, date) {
                    tbNewStartDate.config.max = {
                        year: date.year,
                        month: date.month - 1,
                        date: date.date,
                        hours: 0,
                        minutes: 0,
                        seconds: 0
                    };
                    if ($.trim(value) == "") {
                        tbNewFinishDate.config.min = tbNewStartDate.config.min;
                        tbNewStartDate.config.max = tbNewFinishDate.config.max;
                    }
                }
            });
        });
    });
</script>